import axios from "../util/request";

//home页面数据请求
export const homelist = () => {
  return axios.get(`/adminapi/home/header`);
};

export function getDiscountList(val) {
  return axios({
    url:
      "adminapi/marketing/coupon/list?page=" +
      val.page +
      "&limit=" +
      val.limit +
      "&status=" +
      val.status +
      "&title=" +
      val.title,
    method: "get",
  });
}

export function getHistory(val) {
  return axios({
    url: `adminapi/marketing/coupon/released/issue_log/${val}`,
    method: "get",
  });
}

export function getHistoryList(val) {
  return axios({
    url: `/adminapi/marketing/coupon/user?status=${val.status}&coupon_title=${val.coupon_title}&nickname=${val.nickname}&page=${val.page}&limit=${val.limit}`,
    method: "get",
  });
}

export function delDiscount(val) {
  return axios({
    url: "/adminapi/marketing/coupon/del/" + val,
    method: "DELETE",
  });
}

export function getClassifyList(val) {
  return axios({
    url:
      "/adminapi/product/category?limit=" +
      val.limit +
      "&page=" +
      val.page +
      "&is_show=" +
      val.is_show +
      "&cate_name=" +
      val.cate_name +
      "&pid=" +
      val.pid,
    method: "GET",
  });
}

export function confirmAdd(val) {
  return axios({
    url: "/adminapi/product/category.html",
    method: "POST",
    data: val,
  });
}

export function configEdit(val) {
  return axios({
    url: "/adminapi/product/category/" + val.id,
    method: "PUT",
    data: val,
  });
}

export function editClassify(val) {
  return axios({
    url: "/adminapi/product/category/9" + val,
    method: "GET",
  });
}

export function getFatherList() {
  return axios({
    url: "/adminapi/product/category/create",
    method: "GET",
  });
}

export function classifyUpload(val) {
  return axios({
    url: "/adminapi/file/category?name=",
    method: "GET",
  });
}

export function switchEdit(val) {
  const { id, is_show } = val;
  return axios({
    url: "/adminapi/product/category/set_show/" + id + "/" + is_show,
    method: "PUT",
  });
}

export function delClassifyList(val) {
  return axios({
    url: "/adminapi/product/category/" + val,
    method: "DELETE",
  });
}

export const login = (val) => {
  return axios.post("/adminapi/login", {
    account: val.name,
    pwd: val.pwd,
    imgcode: val.code,
  });
};

export function list(val) {
  return axios({
    data: val,
    method: "get",
    url: "/adminapi/product/product/type_header",
  });
}

export function fen(val) {
  return axios({
    data: val,
    method: "get",
    url: "/adminapi/product/category/tree/1",
  });
}

export function shop(val) {
  return axios({
    data: val,
    method: "get",
    url:
      "/adminapi/product/product?page=" +
      val.page +
      "&limit=" +
      val.limit +
      "&type=" +
      val.type +
      "&excel=" +
      val.excel,
  });
}

export function cut(val) {
  return axios({
    data: val,
    method: "PUT",
    url: "/adminapi/product/product/set_show/" + val.id + "/" + val.is_show,
  });
}

export function lines(val) {
  return axios({
    data: null,
    method: "get",
    url: "/adminapi/home/user",
  });
}

export function types(val = "30天") {
  return axios({
    data: null,
    method: "get",
    url: "/adminapi/home/order?cycle=thirtyday&thirtyday=" + val,
  });
}

export function tubedel(val) {
  return axios({
    data: val,
    method: "DELETE",
    url: "/adminapi/product/product/" + val,
  });
}
export function MemberAdd(val) {
  return axios({
    data: val,
    method: "post",
    url: "/adminapi/user/user_level.html",
  });
}
export function MemberTable(val) {
  return axios({
    data: val,
    method: "get",
    url:
      "/adminapi/user/user_level/vip_list?is_show=" +
      val.is_show +
      "&page=" +
      val.page +
      "&limit=" +
      val.limit,
  });
}
export function MemberImage(val) {
  return axios({
    data: val,
    method: "post",
    url: "/adminapi/file/upload",
  });
}
export function MemberDel(val) {
  return axios({
    data: val,
    method: "put",
    url: "/adminapi/user/user_level/delete/" + val.id,
  });
}

// 商品评价管理列表获取和筛选
export const getList = (val) => {
  return axios.get(
    `/adminapi/product/reply?is_reply=${val.is_reply}&data=${val.data}&store_name=${val.store_name}&account=${val.account}&product_id=${val.product_id}&page=${val.page}&limit=${val.limit}`
  );
};
// 回复接口
export const reply = (val) => {
  return axios.put("/adminapi/product/reply/set_reply/" + val.id, val.content);
};
// 商品评论删除接口
export const dellist = (params) => {
  return axios.delete(`/adminapi/product/reply/${params.id}`);
};
// 商品评论中商品的分类
export const listarr = (val) => {
  return axios.get("/adminapi/product/category/tree/" + val);
};
// 商品评论中商品的数据列表
export const listTable = (val) => {
  return axios.get(
    `/adminapi/product/product/list?page=${val.page}&limit=${val.limit}&cate_id=${val.cate_id}&store_name=${val.store_name}&is_live=${val.is_live}`
  );
};
// 商品评论中用户头像中的图片
export const image = (val) => {
  return axios.get(
    `/adminapi/file/file?pid=${val.pid}&page=${val.page}&limit=${val.limit}`
  );
};
// 商品评论中用户头像中的全部分类
export const imagelist = () => {
  return axios.get(`/adminapi/file/category?name=`);
};
// 商品评论中用户头像中的图片删除
export const imagedelet = (val) => {
  return axios.post("/adminapi/file/file/delete", val);
};
// 商品评论中用户头像中的图片添加分类
export const imagecreated = (val) => {
  return axios.get("/adminapi/file/category/create?id=0");
};
// 商品评论中用户头像中的图片添加分类中弹出层分类
export const listAdd = (val) => {
  return axios.post("/adminapi/file/category.html", val);
};
// 商品评论中用户头像中的图片上传
export const upimg = (val) => {
  return axios.post("/adminapi/file/upload", val);
};
// 商品评论中用户头像中的图片移动分类
// export const yiimg=(val)=>{
//   return axios.put('/adminapi/file/file/do_move',val)
// }
// 商品评论中用户头像/评价图片搜索图片
// export const listseach=(val)=>{
//   return axios.get(`/adminapi/file/category?name=${val}`)
// }
// 商品评论添加接口
// export const addlist=(val)=>{
//   return axios.post('/adminapi/product/reply/save_fictitious_reply.html',val)
// }
// 用户标签
// 用户标签获取数据
// export const labellist=(val)=>{
//   return axios.get('/adminapi/user/user_label?page='+val.page+'&limit='+val.limit)
// }
// 修改 adminapi/user/user_label/add/
// export const labelelit=(val)=>{
//   return axios.get(`/adminapi/user/user_label/add/${val}`)
// }
// 确认修改  adminapi/user/user_label/save.html
// export const suerlabel=(val)=>{
//   return axios.post('/adminapi/user/user_label/save.html',val)
// }
// 点击添加
// export const addlabel=(val)=>{
//   return axios.get('adminapi/user/user_label/add/0')
// }
// 确认添加
// export const queAddlabel=(val)=>{
//   return axios.post('/adminapi/user/user_label/save.html',val)
// }
// 删除
// export const labeldelete=(params)=>{
//   return axios.delete(`/adminapi/user/user_label/del/${params.id}`)
// }

// 用户分组
// 用户分组获取数据
// export const userlist=(val)=>{
//   return axios.get('/adminapi/user/user_group/list?page='+val.page+'&limit='+val.limit)
// }
// 修改
// export const userelit=(val)=>{
//   return axios.get(`/adminapi/user/user_group/add/${val}`)
// }
// 确认修改
// export const suerelit=(val)=>{
//   return axios.post('/adminapi/user/user_group/save.html',val)
// }
// 点击添加
// export const addlistF=(val)=>{
//   return axios.get('/adminapi/user/user_group/add/0')
// }
// 确认添加
// export const queAdd=(val)=>{
//   return axios.post('/adminapi/user/user_group/save.html',val)
// }

export const yiimg = (val) => {
  return axios.put("/adminapi/file/file/do_move", val);
};
// 商品评论中用户头像/评价图片搜索图片
export const listseach = (val) => {
  return axios.get(`/adminapi/file/category?name=${val}`);
};
// 商品评论添加接口
export const addlist = (val) => {
  return axios.post("/adminapi/product/reply/save_fictitious_reply.html", val);
};
// 用户标签
// 用户标签获取数据
export const labellist = (val) => {
  return axios.get(
    "/adminapi/user/user_label?page=" + val.page + "&limit=" + val.limit
  );
};
// 修改 adminapi/user/user_label/add/
export const labelelit = (val) => {
  return axios.get(`/adminapi/user/user_label/add/${val}`);
};
// 确认修改  adminapi/user/user_label/save.html
export const suerlabel = (val) => {
  return axios.post("/adminapi/user/user_label/save.html", val);
};
// 点击添加
export const addlabel = (val) => {
  return axios.get("adminapi/user/user_label/add/0");
};
// 确认添加
export const queAddlabel = (val) => {
  return axios.post("/adminapi/user/user_label/save.html", val);
};
// 删除
export const labeldelete = (params) => {
  return axios.delete(`/adminapi/user/user_label/del/${params.id}`);
};

// 用户分组
// 用户分组获取数据
export const userlist = (val) => {
  return axios.get(
    "/adminapi/user/user_group/list?page=" + val.page + "&limit=" + val.limit
  );
};
// 修改
export const userelit = (val) => {
  return axios.get(`/adminapi/user/user_group/add/${val}`);
};
// 确认修改
export const suerelit = (val) => {
  return axios.post("/adminapi/user/user_group/save.html", val);
};
// 点击添加
export const addlistF = (val) => {
  return axios.get("/adminapi/user/user_group/add/0");
};
// 确认添加
export const queAdd = (val) => {
  return axios.post("/adminapi/user/user_group/save.html", val);
};

// 删除
export const userdelete = (params) => {
  return axios.delete(`/adminapi/user/user_group/del/${params.id}`);
};

//商品规格数据
export const guigeList = (val) => {
  return axios.get(
    "adminapi/product/product/rule?page=" + val.page + "&limit=" + val.limit
  );
};

export const guigeSearch = (val) => {
  return axios.get(
    "adminapi/product/product/rule?page=" +
      val.page +
      "&limit=" +
      val.limit +
      "&rule_name=" +
      val.name
  );
};

export const guigedel = (val) => {
  return axios.delete("adminapi/product/product/rule/delete?ids=" + val);
};

//订单页面
export const orderdan = (val) => {
  return axios.get("/adminapi/order/chart?type=" + val);
};

export const orderlist = (val) => {
  return axios.get(
    "/adminapi/order/list?page=" +
      val.page +
      "&limit=" +
      val.limit +
      "&status=" +
      val.status +
      "&data=" +
      val.date +
      "&real_name=" +
      val.name +
      "&type=" +
      val.type
  );
};

//订单核销
export const orderdel = (val) => {
  return axios.post("/adminapi/order/write", val);
};

//订单配送信息
export const orderpei = (val) => {
  return axios.get("/adminapi/order/distribution/" + val);
};

//提交订单快递信息
export const orderkuai = (val) => {
  return axios.put("/adminapi/order/distribution/" + val.id, {
    delivery_id: val.danhao,
    delivery_name: val.name,
    order_id: val.wei,
  });
};

//订单发送货
export const orderfa = (val) => {
  return axios.get("/adminapi/order/express_list");
};

export const orderfas = (val) => {
  return axios.put("/adminapi/order/delivery/" + val.id, {
    type: val.type,
    delivery_id: val.danhao,
    delivery_name: val.name,
    sh_delivery_id: "",
    sh_delivery_name: "",
  });
};

//订单编辑页面
export const orderedit = (val) => {
  return axios.get("/adminapi/order/edit/" + val);
};

//订单页面更新
export const orderedits = (val) => {
  return axios.put(`/adminapi/order/update/${val.id}`,val);
};

//订单用户信息页面
export const orderinfo = (val) => {
  return axios.get(`/adminapi/order/info/${val}`);
};

//订单记录列表
export const orderhistory = (val) => {
  return axios.get(`/adminapi/order/status/${val.id}?page=${val.page}&limit=${val.limit}`);
};

//订单打印
export const orderprint = (val) => {
  return axios.get(`/adminapi/order/print/${val}`);
};